import request from '@/service'

export const getCateList = params => {
  return request({
    method: 'Get',
    url: 'categories',
    params
  })
}

// 商品分类数据列表 type:2
export const getParentCateList = params => {
  return request({
    method: 'Get',
    url: 'categories',
    params: {
      type: params
    }
  })
}

// 添加分类
export const getNewCateList = data => {
  return request({
    method: 'post',
    url: 'categories',
    data
  })
}

// 根据分类 id 获取分类详情
export const getCategoryDetail = id => {
  return request({
    method: 'get',
    url: `categories/${id}`
  })
}

// 确认编辑
export const editCate = ({ id, catName }) => {
  return request({
    method: 'PUT',
    url: `categories/${id}`,
    data: {
      cat_name: catName
    }
  })
}
// 删除
export const deleteCategory = id => {
  return request({
    method: 'DELETE',
    url: `categories/${id}`
  })
}
